package zw_501_600.zw_561_数组拆分;

import java.util.Arrays;

class Solution {

    public static void main(String[] args) {
        int[] nums = {6,2,6,5,1,2};
        int sum = arrayPairSum(nums);
        System.out.println(sum);
    }

    public static int arrayPairSum(int[] nums) {
        Arrays.sort(nums);
        int ans = 0;
        for (int i = 0; i < nums.length; i += 2) {
            ans += nums[i];
        }
        return ans;
    }
}
